package com.acme;

import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.Logger;
import java.util.logging.XMLFormatter;

public class MyClass {
    public static void main(final String args[]) {
	try {
	    Logger logger = Logger.getLogger("LoggingExample1");
	    
	    LogManager lm = LogManager.getLogManager();
	    lm.addLogger(logger);
	    
	    logger = lm.getLogger("LoggingExample1");
	    if (logger == null) {
		System.out.println("There is no such logger");
		return;
	    }

	    FileHandler fh = new FileHandler("log.xml");
	    fh.setFormatter(new XMLFormatter());

	    logger.addHandler(fh);

	    logger.setLevel(Level.INFO);

	    logger.log(Level.INFO, "test info");
	    logger.log(Level.SEVERE, "test severe");
	    logger.log(Level.WARNING, "test warning");
	    logger.log(Level.CONFIG, "test config");
	    logger.log(Level.FINE, "test fine");
	    logger.log(Level.FINER, "test finer");
	    logger.log(Level.FINEST, "test finest");

	    fh.close();

	} catch (Exception e) {
	    System.out.println("Exception thrown: " + e);
	    e.printStackTrace();
	}
    }
}
